<template>
    <a-menu theme="dark" mode="inline" :selectedKeys="selecTed" @click="handleClick" style="max-width: 25vh;top: 5vh">
      <a-sub-menu key="1">
        <span slot="title"><a-icon type="user" />{{ currentUser }}<span style="color: #fff"></span></span>
<!--        <a-menu-item key="info">
          用户信息
        </a-menu-item>-->
        <a-menu-item key="logout">
          退出登录
        </a-menu-item>
      </a-sub-menu>
    </a-menu>

</template>

<script>
import  {getUserInfo,removeAccessToken,removeUserInfo} from "@/utils/storageUtil";

export default {
  data() {
    return{
      selecTed:['1'],
      currentUser:''
    }
  },
  methods:{
    handleClick(e){
      this.selecTed = [e.key];
      if (e.key == 'info'){
        this.$message.success('页面开发中');
      }else if (e.key == 'logout'){
        removeAccessToken();
        removeUserInfo();
        this.$router.push('/login');
      }
    }
  },
  created() {
    let user = JSON.parse(getUserInfo());
    this.currentUser = user.userName;
  }
}
</script>

<style>
#components-layout-demo-fixed-sider .logo {
  height: 32px;
  background: rgba(255, 255, 255, 0.2);
  margin: 16px;
}
</style>
